package com.zyl.demo.mapper;

import com.zyl.demo.beans.Category;
import com.zyl.demo.beans.CategorySub;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategorySubMapper {
    @Select("SELECT * FROM t_category_sub")
    List<CategorySub> getAllCategorySub();

    @Insert("insert into t_category_sub(category_sub_name,category_sub_describe,category_sub_img,category_id)" +
            " values(#{categorySubName},#{categorySubDescribe},#{categorySubImg},#{categoryId})")
    int addCategorySub(CategorySub categorySub);

    @Delete("delete from t_category_sub where category_sub_id=#{categorySubId}")
    int deleteCategorySub(int categorySubId);

    @Select("SELECT *FROM t_category_sub WHERE category_id =#{categoryId}")
    List<CategorySub> getCategorySubByCategoryId(int categoryId);

}
